import java.util.Scanner;

//求斐波那契数列的第n项。(迭代实现)
public class Fabonac {
    public static int fabona(int n){
        int a =1;
        int b =1;
        int ret = 1;
        if (n <= 2){//前两个斐波那契数为1
            return ret;
        } else {
            for (int i = 2; i < n; i++) {//第n个==前面两个相加
                ret = a + b;
                a = b;
                b = ret;
            }
            return ret;
        }
    }
    public static void main(String[] args) {
        System.out.println("请输入n");
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        int b=fabona(n);
        System.out.println("第"+n+"项斐波那契数为："+b);
    }
}
